/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package utils;

import utils.dataaccess.DBInterface;
import entities.Forumblocks;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author Dezmond
 */
@FacesConverter(forClass=entities.Forumblocks.class, value="blocksConverter")
public class BlocksConverter implements Converter{

        @Override
        public Object getAsObject(FacesContext context, UIComponent component, String value) {
            System.out.println("Conv "+value); 
            return DBInterface.getBlockByName(value);
        }

        @Override
        public String getAsString(FacesContext context, UIComponent component, Object value) {
            return ((Forumblocks)value).toString();
        }

    }
